<template>
    <div>
        <el-form ref="form"
                 :model="form"
                 label-width="150px"
                 :label-position="labelPosition"
                 style="margin-left:5%">
            <div>
                <el-button type="primary" icon="el-icon-edit" plain round size="mini" style="margin:2% 5%"
                           @click="showDialog">修 改
                </el-button>

            </div>
            <div v-if="_self.form.state === 2">
                <span>管理人要求补正的材料 ：{{form.checkedNote}}</span>
            </div>
            <el-form-item label="债权人身份 ：">
                <span>{{form.identityType}}</span>
            </el-form-item>
            <el-form-item label="申报模式 ：">
                <span>{{form.agentType}}</span>
            </el-form-item>
            <div v-if="form.identityType === '个人'">
                <el-form-item label="债权人姓名 ：">
                    <span>{{form.name}}</span>
                </el-form-item>
                <el-form-item label="债权人证件类型 ：">
                    <span>{{form.idType}}</span>
                </el-form-item>
                <el-form-item label="债权人身份证号 ：">
                    <span>{{form.idcard}}</span>
                </el-form-item>
                <el-form-item label="债权人证件照正面 ：">
                    <img :src="form.idcardFront" style="width: 100%">
                </el-form-item>
                <el-form-item label="债权人证件照反面 ：">
                    <img :src="form.idcardReverse" style="width: 100%">
                </el-form-item>
                <el-form-item label="债权人手机号 ：">
                    <span>{{form.mobile}}</span>
                </el-form-item>
                <el-form-item label="债权人邮箱 ：">
                    <span>{{form.email}}</span>
                </el-form-item>
                <el-form-item label="债权人座机 ：">
                    <span>{{form.tel}}</span>
                </el-form-item>
                <el-form-item label="债权人地址 ：">
                    <span>{{form.address}}</span>
                </el-form-item>
            </div>
            <div v-if="form.identityType=== '公司（机构）'">
                <el-form-item label="机构名称 ：">
                    <span>{{form.orgName}}</span>
                </el-form-item>
                <el-form-item label="统一社会信用代码 ：">
                    <span>{{form.orgCode}}</span>
                </el-form-item>
                <el-form-item label="邮箱 ：">
                    <span>{{form.email}}</span>
                </el-form-item>
                <el-form-item label="联系电话 ：">
                    <span>{{form.tel}}</span>
                </el-form-item>
                <el-form-item label="约定送达地址 ：">
                    <span>{{form.address}}</span>
                </el-form-item>
                <el-form-item label="法定代表人姓名 ：">
                    <span>{{form.name}}</span>
                </el-form-item>
                <el-form-item label="法定代表人证件类型：">
                    <span>{{form.idType}}</span>
                </el-form-item>
                <el-form-item label="法定代表人身份证号：">
                    <span>{{form.idcard}}</span>
                </el-form-item>
                <el-form-item label="法定代表人（负责人）证件照正面或证件照一 ：">
                    <img :src="form.idcardFront" style="width: 100%">
                </el-form-item>
                <el-form-item label="法定代表人（负责人）证件照背面或证件照二 ：">
                    <img :src="form.idcardReverse" style="width: 100%">
                </el-form-item>
                <el-form-item label="法定代表人手机号 ：">
                    <span>{{form.mobile}}</span>
                </el-form-item>
            </div>
            <div v-if="form.identityType=== '行政机关（金融机构）'">
                <el-form-item label="行政机关（金融机构）名称 ：">
                    <span>{{form.orgName}}</span>
                </el-form-item>
                <el-form-item label="邮箱 ：">
                    <span>{{form.email}}</span>
                </el-form-item>
                <el-form-item label="约定送达地址 ：">
                    <span>{{form.address}}</span>
                </el-form-item>
                <el-form-item label="联系电话 ：">
                    <span>{{form.tel}}</span>
                </el-form-item>
                <el-form-item label="负责人 ：">
                    <span>{{form.name}}</span>
                </el-form-item>
                <el-form-item label="手机号 ：">
                    <span>{{form.mobile}}</span>
                </el-form-item>
            </div>
            <el-form-item label="收款银行 ：">
                <span>{{form.bankName}}</span>
            </el-form-item>
            <el-form-item label="账号 ：">
                <span>{{form.bankAccount}}</span>
            </el-form-item>
            <el-form-item label="收款银行户名 ：">
                <span>{{form.bankUname}}</span>
            </el-form-item>

            <div v-if="form.agentType==='特别申报'">
                <el-form-item label="真实债权人名称 ：">
                    <span>{{form.specialCreditor}}</span>
                </el-form-item>
                <el-form-item label="特别申报说明 ：">
                    <el-input type="textarea" disabled v-model="form.specialNote"
                              :autosize="{ minRows: 4, maxRows: 10}"></el-input>
                </el-form-item>
                <el-form-item label="特别申报文件 ：">
                    <el-table
                            :data="especiallyFileList"
                            border
                            style="width: 100%">
                        <el-table-column
                                prop="name"
                                label="文件名">
                        </el-table-column>
                    </el-table>
                </el-form-item>
            </div>

            <div v-if="form.agentType==='代理人'">
                <el-form-item label="代理人证件照正面 ：">
                    <img :src="form.agentDetailInfo.idcardFront" style="width: 100%">
                </el-form-item>
                <el-form-item label="代理人证件照反面 ：">
                    <img :src="form.agentDetailInfo.idcardReverse" style="width: 100%">
                </el-form-item>
                <el-form-item label="代理人姓名 ：">
                    <span>{{form.agentDetailInfo.name}}</span>
                </el-form-item>
                <el-form-item label="代理人类型 ：">
                    <span>{{form.agentDetailInfo.identityType}}</span>
                </el-form-item>
                <el-form-item label="代理人证件类型 ：">
                    <span>{{form.agentDetailInfo.idType}}</span>
                </el-form-item>
                <el-form-item label="代理人证件号码 ：">
                    <span>{{form.agentDetailInfo.idcard}}</span>
                </el-form-item>
                <el-form-item label="代理人手机号 ：">
                    <span>{{form.agentDetailInfo.mobile}}</span>
                </el-form-item>
                <el-form-item label="代理人邮箱 ：">
                    <span>{{form.agentDetailInfo.email}}</span>
                </el-form-item>
                <el-form-item label="代理人联系地址 ：">
                    <span>{{form.agentDetailInfo.address}}</span>
                </el-form-item>
            </div>
        </el-form>
        <el-dialog title="" :visible.sync="registerVisible" width="95%" center>
            <el-form ref="form" :model="form1" :label-width="formLabelWidth">
                <!--   <el-form-item label="债权人身份: ">
                       <el-select v-model="identityType" placeholder="请选择" @change="identityTypeChange">
                           <el-option
                                   v-for="nature in creditType"
                                   :key="nature.value"
                                   :label="nature.value"
                                   :value="nature.value">
                           </el-option>
                       </el-select>
                   </el-form-item>
                   <el-form-item label="申报模式: ">
                       <el-radio-group v-model="agentType">
                           <el-radio label="代理人" style="margin-top: 20px" ></el-radio><br/>
                           <el-radio label="本人"  style="margin-top: 20px" v-if="_self.identityType==='个人'"></el-radio><br/>
                           <el-radio label="特别申报" style="margin-top: 20px" v-if="_self.identityType==='个人'"></el-radio><br/>
                       </el-radio-group>
                   </el-form-item>-->
                <!-- <el-dialog
                                       width="70%"  center
                                       title="修改债权人身份"
                                       :visible.sync="innerVisible"
                                       append-to-body>
                                   <el-radio-group v-model="identityType">
                                       <el-radio label="个人" style="margin-top: 20px"></el-radio><br/>
                                       <el-radio label="公司（机构）"  style="margin-top: 20px" ></el-radio><br/>
                                       <el-radio label="行政机关（金融机构）" style="margin-top: 20px"></el-radio><br/>
                                   </el-radio-group>
                                   <span slot="footer" >
                                   <el-button type="primary" @click="innerVisible = false">取消</el-button>
                                   <el-button @click="toAmendCreditor" type="primary">确定</el-button>
                               </span>
                               </el-dialog>-->
                <el-form-item label="修改: ">
                    <el-radio-group v-model="amend">
                        <el-radio :label="1" style="margin-top: 20px">修改债权人信息</el-radio>
                        <br/>
                       <!-- <el-radio :label="2" style="margin-top: 20px" v-if="this.form.agentDetailInfo !== '' ">修改代理人信息</el-radio>-->
                        <el-radio :label="2" style="margin-top: 20px" v-if="_self.agentType === '代理人' ">修改代理人信息</el-radio>
                        <br/>
                    </el-radio-group>
                </el-form-item>

            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="registerVisible = false">取消</el-button>
                <el-button @click="toRegister" type="primary">确定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
    import util from 'assets/js/util.js'

    export default {
        data() {
            return {
                especiallyFileList: [],
                labelPosition: 'left',
                form1: {},

                /* form1: {
                     nature: '个人',
                     agentType: '否',
                     attendState: '参加尚不确定'
                 },
                 creditType: [
                     {
                         value: '个人'
                     }, {
                         value: '公司（机构）'
                     }, {
                         value: '行政机关（金融机构）'
                     }
                 ],*/
                agentType: '',
                identityType: '',
                registerVisible: false,
                formLabelWidth: '150px',
                agentDetailInfo:[],
                amend: 1,
                innerVisible: false,
            };

        },
        props: [
            'form',
        ],
        mounted() {
            this.agentType = this.form.agentType;
            this.identityType = this.form.identityType;
            this.agentDetailInfo = this.form.agentDetailInfo;
        },

        methods: {
            matchIdentityType: function (identityType) {
                let temp = 1;
                switch (identityType) {
                    case "个人":
                        temp = 1;
                        break;
                    case "公司（机构）":
                        temp = 2;
                        break;
                    case "行政机关（金融机构）":
                        temp = 3;
                        break;
                }
                return temp;
            },

            matchAgentType: function (identityType) {
                let temp = 1;
                switch (identityType) {
                    case "代理人":
                        temp = 1;
                        break;
                    case "本人":
                        temp = 0;
                        break;
                    case "特别申报":
                        temp = 2;
                        break;
                }
                return temp;
            },
            identityTypeChange: function (identityType) {
                this.agentType = "代理人";
            },

            toRegister: function () {
                // window.location.href = '../register/register-creditor.html?agentType=' + this.matchAgentType(this.agentType) + "&identityType=" + this.matchIdentityType(this.identityType);
                if (this.amend === 2) {
                    window.location.href = '../register/register-creditor.html?agentType=' +
                        this.matchAgentType(this.agentType)
                        + "&identityType=" + this.matchIdentityType(this.identityType);
                } else {
                    window.location.href = '../register/register-creditor.html?' + "identityType=" + this.matchIdentityType(this.identityType)
                }

            },
            showDialog: function () {
                this.registerVisible = true;
            }
        }
    }
</script>

<style>

</style>
